package com.xiaojun.whut.Config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author 鲁佳磊
 * @create 2020-10-31 19:50
 */
//新增跨域请求

public class CorsConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")// 允许访问的一个路径的的请求
                .allowedOrigins("http://localhost:8080","null")//允许访问的域
                .allowedMethods("GET","POST","DELETE","OPTIONS","PUT")//允许访问的访问方法
                .allowCredentials(true)//是否cookik信息信息
                .maxAge(3600);//最长响应事件时间
    }


}
